<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="author" content="wangbo">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>location</title>
</head>
<body>
    <a href="#pid">我是a标签</a>
    <p id="pid">我是锚点</p>
    <input type="button" onclick="location.reload()" value="重新加载">
    <input type="button" onclick="location.reload()" value="重新加载">
    <!-- location window 的对象 -->
    <script type="text/javascript">
    console.log(window.location)
    console.log(window.location.host)
    console.log(window.location.hostname)
    document.writeln('hash锚点'+window.location.hash+"<br>")
    document.writeln('页面路径'+window.location.pathname+"<br>")
    document.writeln('端口'+window.location.port+"<br>")
    document.writeln('端口协议'+window.location.protocol+"<br>")
    document.writeln('完整的链接'+window.location.href+"<br>")
    // 还可以跳转路径
    // window.location.href ="https://www.w3cschool.cn/jsref/obj-location.html";
    // 替换原文档
    location.replace("https://www.w3cschool.cn/jsref/obj-location.html")
    </script>
    
</body>
</html>